<template>

  <div>
    <a-card :bordered="false" class="card-info mb-24 widget-1" style="margin-left: 12px;margin-right: 12px; ">
      <h4 style="margin-bottom: 50px">诈骗反馈中心</h4>
      <a-row :gutter="24"  >
        <a-col :span="24" :lg="24" class="mb-24">
          <a-input placeholder="标题" v-model="caseUpdateVo.caseInfo.tittle"/>
        </a-col>

      </a-row>

      <a-row :gutter="24"  >
        <a-col :span="24" :lg="5" class="mb-24">
          <a-input placeholder="行骗者相关联系方式"  v-model="caseUpdateVo.perpetratorInfo.contact"/>
        </a-col>
        <a-col :span="24" :lg="5" class="mb-24">
          <a-input placeholder="受害者相关联系方式" v-model="caseUpdateVo.caseInfo.contact"/>
        </a-col>
        <a-col :span="24" :lg="4" class="mb-24">
          <a-select default-value="选择类型" style="width: 120px" @change="handleChange">
            <a-select-option value="账号交易">
              账号交易
            </a-select-option>
            <a-select-option value="游戏代练">
              游戏代练
            </a-select-option>
            <a-select-option value="交流诈骗">
              交流诈骗
            </a-select-option>
            <a-select-option value="其他">
              其他
            </a-select-option>
          </a-select>
        </a-col>
        <a-col :span="24" :lg="10" class="mb-24">
          <a-alert message="您的信息仅提供给管理核实信息，平台不会泄露您的信息" type="warning" show-icon />
        </a-col>

      </a-row>



      <Editor ref="editor"></Editor>

      <a-row :gutter="24"  style="margin-top: 70px">
        <a-col :span="24" :lg="24" class="mb-24">
          <a-button  target="_blank" type="primary" shape="round" @click="submit">提交</a-button>
        </a-col>

      </a-row>

    </a-card>


  </div>
</template>

<script>

import Editor from "@/components/Editor";

export default {
  components:{
    Editor
  },
  data(){
    return{
      formData:{
        tittle: '',
        //TODO: 名称待定
        jugglerInfo: '',
        suffererInfo: '',
        type: '',
        content: ''
      },
      caseUpdateVo :{
        caseInfo: {
          acceptAuditors: "",

          contact: "",
          details: "",

          providePersonId: "",
          status: "",
          tittle: "",
          type: ""
        },
        htmlDetails: "",
        perpetratorInfo: {
          contact: "",
          email: "",
          idCard: "",
          image: "",
          name: "",

          phone: "",
          sex: ""
        }
      }
    }
  },
  name: "CaseDetails",
  methods:{
    handleChange(value) {
      console.log(`selected ${value}`);
      this.caseUpdateVo.caseInfo.type = value
    },
    insertData(caseUpdateVo){
      this.$axios({
        headers: {
          "Content-Type": "application/json;charset=UTF-8",
          "Authorization": sessionStorage.getItem("systemToken")
        },
        url: "/api/case/insertCase", //后端请求的路径
        method: "post",
        data: caseUpdateVo
      }).then((response) => {
        console.log(response)
        if (response.data.status === 0) {
          swal("案例提交成功","","success")
              .then((e) => {
                this.backHistory();
              })
        }else {
          swal("系统错误","","warning")
              .then((e) => {
                this.backHistory();
              })
        }
      });
    },
    backHistory(){
      this.$router.go(-1);
    },
    submit(){
      // console.log(this.$refs.editor.content);
      //TODO: 双引号替换单引号
      this.caseUpdateVo.caseInfo.providePersonId = sessionStorage.getItem("userId")
      this.caseUpdateVo.htmlDetails = this.$refs.editor.content.replace(/\"/g,"'")

      this.insertData(this.caseUpdateVo)
    }
  }
}
</script>

<style lang="scss">

</style>